package dynamic.ibatis.builder;

import java.util.List;

import dynamic.ibatis.mapping.DDiscriminator;
import dynamic.ibatis.mapping.DResultMap;
import dynamic.ibatis.mapping.DResultMapping;
import org.apache.ibatis.mapping.Discriminator;
import org.apache.ibatis.mapping.ResultMapping;

/**
 * @author Eduardo Macarron
 */
public class DResultMapResolver {
    private final DMapperBuilderAssistant assistant;
    private final String id;
    private final Class<?> type;
    private final String extend;
    private final DDiscriminator discriminator;
    private final List<DResultMapping> resultMappings;
    private final Boolean autoMapping;

    public DResultMapResolver(DMapperBuilderAssistant assistant, String id, Class<?> type, String extend,
                              DDiscriminator discriminator, List<DResultMapping> resultMappings, Boolean autoMapping) {
        this.assistant = assistant;
        this.id = id;
        this.type = type;
        this.extend = extend;
        this.discriminator = discriminator;
        this.resultMappings = resultMappings;
        this.autoMapping = autoMapping;
    }

    public DResultMap resolve() {
        return assistant.addResultMap(this.id, this.type, this.extend, this.discriminator, this.resultMappings,
                this.autoMapping);
    }

}
